import numpy as np

a = np.arange(18).reshape(3,2,3)
print(a)

# 选定哪个axis,就只有这一个axis的值是可以取范围聚合的
# [
#   [(max(a000, a100, a200), max(a001, a101, a201), max(a002, a102, a202))],
#   [(max(a010, a110, a210), max(a011, a111, a211), max(a012, a112, a212))],
# ]
print(a.max(axis=0))
# [
#   [(max(a000, a010), max(a001, a011), max(a002, a012))],
#   [(max(a100, a110), max(a101, a111), max(a102, a112))],
#   [(max(a200, a210), max(a201, a211), max(a202, a212))],
# ]
print(a.max(axis=1))
# [
#   [(max(a000, a001, a002), max(a010, a011, a012))],
#   [(max(a100, a101, a102), max(a110, a111, a112))],
#   [(max(a200, a201, a202), max(a210, a211, a212))],
# ]
print(a.max(axis=2))

# 其他函数: min,mean
print(a.mean(axis=1))

arr = np.arange(18)
np.random.shuffle(arr)
# argmin(求最小值下标),argmax(求最大值下标)
print(arr)
# 实际上arr.argmin(axis=1)求的是
# argmin(a010,a020)   argmin(a011,a021)   argmin(a012,a022)
# argmin(a110,a120)   argmin(a111,a121)   argmin(a112,a122)
# argmin(a210,a220)   argmin(a211,a221)   argmin(a212,a222)
print(arr.argmin(axis=1))

